package main

import (
	"fmt"
)

func main() {
	week := (365 + 1) % 7                 //1901.1.1是星期几
	fmt.Println(sumSunday(week, 1901, 1)) //从1901年1月开始
}

func sumSunday(week, year, month int) int {
	if year == 2001 {
		return 0
	}
	monthdays := 0
	if month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12 {
		monthdays = 31
	} else if month == 2 {
		monthdays = febDays(year)
	} else {
		monthdays = 30
	}
	if month == 12 {
		month = 1
		year++
	} else {
		month++
	}
	nextweek := (week + monthdays) % 7
	if week == 0 {
		return sumSunday(nextweek, year, month) + 1
	}
	return sumSunday(nextweek, year, month)
}

// days 二月份天数
func febDays(year int) int {
	if year%400 == 0 || (year%100 != 0 && year%4 == 0) {
		return 29
	}
	return 28
}
